package main

import (
	"fmt"
	"sync"
)

type Counter struct {
	value int
	mutex sync.Mutex
}

func (c *Counter) Incr() {
	c.mutex.Lock()
	defer c.mutex.Unlock()
	c.value++
}

func main() {
	counter := Counter{}
	var wg sync.WaitGroup
	for i:=0; i<10; i++ {
		wg.Add(1)
		go func() {
			defer wg.Done()
			counter.Incr()
		}()
	}
	wg.Wait()
	fmt.Println(counter.value)
}